package com.yunda.nebula.gateway.service.impl.stat;

import com.yunda.nebula.gateway.service.StatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * \* User: wei.zhang
 * \* Date: 2019/11/4 16:25
 * \* Description:
 * \
 */
@Slf4j
@Service
public class MemoryStatService implements StatService {
    private Map<String, AtomicInteger> count = new ConcurrentHashMap<>();


    @Override
    public void stat(String url) {
        log.info("通过的url 是 {}",url);
        if (!count.containsKey(url)){
            count.put(url,new AtomicInteger(0));
        }
        count.get(url).incrementAndGet();
    }

    @Override
    public StatInfo getStatInfo() {
        return new StatInfo();
    }
}
